//HY11 23N1_2
#include "PlatformProperty.h"
// [SW_FC_004_045]第一排座垫折叠调节1stRowSeatCushionTiltAdjustment - 实时位置
SYSTEM_READ_PROPERTY(SEAT_TILT_POS, int32_t) {
    builder.area(VehicleAreaSeat::ROW_1_LEFT)
            .initValue([]() {
                return 0;
            })
            .withStatusBySignals([]([[maybe_unused]] const PropertyStatus &lastStatus) {
                VHALOG.d("SEAT_TILT_POS DRVR cc468[%d], cc1173[%d], cc184[%d]",
                    SIGNAL.getcarconfig468(), SIGNAL.getcarconfig1173(), SIGNAL.getcarconfig184());

                if (SIGNAL.carConfigIs(SignalRX::carconfig468, sdb::CarConfig468::_02,sdb::CarConfig468::_03) &&
                    SIGNAL.carConfigIs(SignalRX::carconfig1173, sdb::CarConfig1173::_02) &&
                    SIGNAL.carConfigIs(SignalRX::carconfig184, sdb::CarConfig184::_02,
                                       sdb::CarConfig184::_03, sdb::CarConfig184::_04)) {
                    VHALOG.d("SEAT_TILT_POS DRVR Active");
                    return PropertyStatus::Active;
                }  
                VHALOG.d("SEAT_TILT_POS DRVR NotAvailable");
                return PropertyStatus::NotAvailable;
            },
            SignalRX::carconfig1173, 
            SignalRX::carconfig468, 
            SignalRX::carconfig184)
            .withValueBySignals([]([[maybe_unused]] const int32_t &last) {
                //座椅坐垫实时位置
                auto frntHeiPerc = static_cast<int32_t>(SIGNAL.getDrvrSeatPosPercSeatPosFrntHeiPerc());
                //信号质量
                bool qfIsReaday = SIGNAL.getDrvrSeatPosPercSeatPosFrntHeiQF() == sdb::Qf1::DataCalcdWithDevDefd;
                VHALOG.d("SEAT_TILT_POS DRVR withValueBySignals frntHeiPerc[%d],qfIsReaday[%d]",frntHeiPerc,static_cast<int32_t>(qfIsReaday));
                if (frntHeiPerc >= 0 && frntHeiPerc <= 100 && qfIsReaday){
                    return frntHeiPerc;
                }
                return last;
            },
            SignalRX::DrvrSeatPosPercSeatPosFrntHeiPerc,
            SignalRX::DrvrSeatPosPercSeatPosFrntHeiQF)
            .area(VehicleAreaSeat::ROW_1_RIGHT)
            .initValue([]() {
                return 0;
            })
            .withStatusBySignals([]([[maybe_unused]] const PropertyStatus &lastStatus) {
                 VHALOG.d("SEAT_TILT_POS PASS cc468[%d], cc1174[%d], cc184[%d]",
                    SIGNAL.getcarconfig468(), SIGNAL.getcarconfig1174(), SIGNAL.getcarconfig184());

                if (SIGNAL.carConfigIs(SignalRX::carconfig468, sdb::CarConfig468::_02) &&
                    SIGNAL.carConfigIs(SignalRX::carconfig1174, sdb::CarConfig1173::_02) &&
                    SIGNAL.carConfigIs(SignalRX::carconfig184, sdb::CarConfig184::_04)) {
                    VHALOG.d("SEAT_TILT_POS PASS Active");
                    return PropertyStatus::Active;
                }  
                VHALOG.d("SEAT_TILT_POS PASS NotAvailable");
                return PropertyStatus::NotAvailable;
            },
            SignalRX::carconfig1174, 
            SignalRX::carconfig468, 
            SignalRX::carconfig184)
            .withValueBySignals([]([[maybe_unused]] const int32_t &last) {
                //座椅坐垫实时位置
                auto frntHeiPerc = static_cast<int32_t>(SIGNAL.getPassSeatPosPercSeatPosFrntHeiPerc());
                //信号质量
                bool qfIsReaday = SIGNAL.getPassSeatPosPercSeatPosFrntHeiQF() == sdb::Qf1::DataCalcdWithDevDefd;

                VHALOG.d("SEAT_TILT_POS DRVR withValueBySignals frntHeiPerc[%d],qfIsReaday[%d]",frntHeiPerc,static_cast<int32_t>(qfIsReaday));

                if (frntHeiPerc >= 0 && frntHeiPerc <= 100 && qfIsReaday){
                    return frntHeiPerc;
                }
                return last;
            },
            SignalRX::PassSeatPosPercSeatPosFrntHeiQF,
            SignalRX::PassSeatPosPercSeatPosFrntHeiPerc);
}
